/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package sopraim.presenter.validate;

import sopraim.model.Model;

/**
 *
 * @author justeabel
 */
public class DeleteUserForm {
    
    public DeleteUserForm(String admin, String toDelete)throws Exception{
       // validateAdmin(admin);
        validateToDelete(toDelete);
    }
    
     private void validateAdmin(String admin) throws Exception {
        if(admin == null) 
            throw(new Exception("Error : admin is empty"));
        if (admin.trim().isEmpty())
            throw(new Exception("Error : admin is only composed of space"));
        if (!Model.getInstance().getUserDAO().findByLogin(admin).getIsAdmin())
            throw(new Exception("Error : you do not have the admin rights"));
    }
    private void validateToDelete(String toDelete) throws Exception
    {
        if(toDelete == null) 
            throw(new Exception("Error : toDelete is empty"));
        if (toDelete.trim().isEmpty())
            throw(new Exception("Error : toDelete is only composed of space"));
    }
}
